package com.yanqu.road.server.logic.activity.condition.seacraft;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.args.SeacraftPirateRiotScoreRankArgs;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseNewRankActivityCondition;
import com.yanqu.road.server.logic.activity.condition.BaseUserYRankCondition;

import java.math.BigInteger;

public class SeacraftPirateRiotScoreRankCondition extends BaseUserYRankCondition {

    public SeacraftPirateRiotScoreRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        SeacraftPirateRiotScoreRankArgs args = (SeacraftPirateRiotScoreRankArgs) object;

        BigInteger score = BigInteger.valueOf(args.getScore());
        int chapterId = args.getChapterId();

        setValue(score);
        setParam(String.valueOf(chapterId)); // 关卡

        //重新生成排行榜
        rankChange();
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.SeacraftPirateRiotScoreRank.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.SeacraftPirateRiotScoreRank.getValue(), handle);
    }
}
